﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../../Comm/Style/Table0.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/CommonUnite.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>

    <!-- 增加一个配置  -->
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>
    <script src="../../../Scripts/PinYin.js" type="text/javascript"></script>
    <script src="../js/ueditor/dialogs/internal.js"></script>
    <script src="../../../../DataUser/JSLibData/CommonShowConfig.js"></script>
    <script src="Public.js"></script>
    <script type="text/javascript">
        var fk_mapData = GetQueryString("FK_MapData");
        var dataType = GetQueryString("DataType");
        $(function () {

            var Ele_TBName = document.getElementById("TB_Name");
            Ele_TBName.focus();

            PageTransfer_value = dataType; //取出页面传至
            //给单选赋值
            if (PageTransfer_value == "Text" || PageTransfer_value == "Textarea") {
                $("#RB_String").attr("checked", true);
            }

            if (PageTransfer_value == "Int") {
                $("#RB_Int").attr("checked", true);
            }

            if (PageTransfer_value == "Float") {
                $("#RB_Float").attr("checked", true);
            }

            if (PageTransfer_value == "Money") {
                $("#RB_Money").attr("checked", true);
            }

            if (PageTransfer_value == "Date") {
                $("#RB_Date").attr("checked", true);
            }

            if (PageTransfer_value == "DateTime") {
                $("#RB_DateTime").attr("checked", true);
            }

            if (PageTransfer_value == "CheckBox") {
                $("#RB_Boolen").attr("checked", true);
            }
            if (PageTransfer_value == "SignCheck")
                $("#RB_SignCheck").attr("checked", true);

            if (PageTransfer_value == "FlowBBS")
                $("#RB_FlowBBS").attr("checked", true);

            $('#TB_Name').blur(function () //文本失去焦点时触发的事件
            {
                var name = document.getElementById("TB_Name").value;
                var val = $('input:radio[name="RB_qpjp"]:checked').val();
                if (name == "") {
                    document.getElementById("TB_KeyOfEn").value = "";
                    return;
                }

                if (val == "ziduanquanpin")
                    ParsePinYin(name, true, "TB_KeyOfEn");
                else
                    ParsePinYin(name, false, "TB_KeyOfEn");

            });
            //点击全拼
            $('input[id=RB_qp]').change(function () {
                var name = document.getElementById("TB_Name").value;
                ParsePinYin(name, true, "TB_KeyOfEn");
            });
            //点击简拼
            $('input[id=RB_jp]').change(function () {
                var name = document.getElementById("TB_Name").value;
                ParsePinYin(name, false, "TB_KeyOfEn");
            });

            var fname = GetQueryString("fname");
            var name = GetQueryString("name");
            $("#TB_KeyOfEn").val(fname);
            $("#TB_Name").val(name);
        });

        var oNode = null, thePlugins = 'text';
        dialog.oncancel = function () {
            if (UE.plugins[thePlugins].editdom) {
                delete UE.plugins[thePlugins].editdom;
            }
        };
        dialog.onok = function () {

            var name = $.trim($("#TB_Name").val());
            var KeyOfEn = $.trim($("#TB_KeyOfEn").val());
            var IsCreateLabel = $("#CB_scbq").prop("checked");
            var IsHidenField = $("#CB_sfyczd").prop("checked");
            var FieldType = $('input:radio[name=Field_Type]:checked').val();
            if (name == null || name.length == 0) {
                $.messager.alert('错误', '字段名称不能为空。', 'error');
                return false;
            }
            if (KeyOfEn == null || KeyOfEn.length == 0) {
                $.messager.alert('错误', '英文字段不能为空。', 'error');
                return false;
            }

            if (dataType == "FlowBBS" || FieldType == 15) {
                var ens = new Entities("BP.Sys.MapAttrs");
                ens.Retrieve("FK_MapData", fk_mapData, "UIContralType", 15);
                if (ens.length > 0) {
                    $.messager.alert('错误', '表单中只能存在一个评论组件，表单' + fk_mapData + '已经存在评论组件不能再增加', 'error');
                    return false;
                }
            }

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_FoolFormDesigner");
            handler.AddPara("FK_MapData", fk_mapData);
            handler.AddPara("KeyOfEn", KeyOfEn);
            handler.AddPara("name", name);
            handler.AddPara("FType", FieldType == 14 || FieldType == 15 ? 1 : FieldType);
            handler.AddPara("IsSupperText", dataType == "Textarea" ? 1 : 0)
            if (dataType == "SignCheck" || FieldType == 14)
                handler.AddPara("UIContralType", 14);
            if (dataType == "FlowBBS" || FieldType == 15)
                handler.AddPara("UIContralType", 15);

            var data = handler.DoMethodReturnString("FieldTypeSelect_Create");
            if (data.indexOf("err@") != -1) {
                $.messager.alert('错误', data.replace('err@', ''), 'error');
                return false;
            }

            //插入到html 到编辑器.
            if (dataType != "Textarea") {
                dataType = GetFieldType(FieldType, dataType);
                InsertHtmlToEditor(dataType, KeyOfEn, name);
            } else if (dataType == "Textarea") {
                InsertHtmlToEditor(dataType, KeyOfEn, name, null, null, FieldType);
            }


        };
        //类型转换
        function GetFieldType(FieldType, dataType) {
            if (FieldType == "1") {
                if (dataType == "SignCheck")
                    return "SignCheck";
                if (dataType == "FlowBBS")
                    return "FlowBBS";
                return "Text";
            } else if (FieldType == "2") {
                return "Int";
            } else if (FieldType == "3") {
                return "Float";
            } else if (FieldType == "4") {
                return "CheckBox";
            } else if (FieldType == "5") {
                return "Double";
            } else if (FieldType == "6") {
                return "Date";
            } else if (FieldType == "7") {
                return "DateTime";
            } else if (FieldType == "8") {
                return "Money";
            } else if (FieldType == "14") {
                return "SignCheck";
            } else if (FieldType == "15") {
                return "FlowBBS";
            }

        }

        //在这里把返回值获取到，放入到对应的文本框里.
        function SelectOne() {

            var url = "../../FoolFormDesigner/FieldTypeListChoseOneFieldExt.htm?FK_MapData=" + GetQueryString("FK_MapData");
            SetHref(url);
        }

        function ToTemplate() {
            var url = "./Fields.htm?FK_MapData=" + GetQueryString("FK_MapData");
            SetHref(url);
        }

    </script>
</head>
<body>
    <form id="from1" action="">
        <table class="Table" cellpadding="0" cellspacing="0" border="0" style="width: 95%;margin:5px;">
            <tr>
                <th colspan="2">
                    <div style="float: left">
                        字段中文名称
                    </div>
                    <div style="float: right" id="Temp0">
                        <!--<a href="javascript:HidAttr();">隐藏字段</a>|-->
                        <a href="javascript:ToTemplate();">常用字段模版</a>
                    </div>
                </th>
            </tr>

            <tr>
                <td>
                    <input id="TB_Name" class="easyui-textbox" style="width: 200px" />
                </td>
                <td rowspan="4">
                    <input id="RB_String" type="radio" name="Field_Type" value="1" checked="checked" /><label for="RB_String">文字类型(地址、电话、公司名称)</label><br />
                    <input id="RB_Int" type="radio" name="Field_Type" value="2" /><label for="RB_Int">整数类型(年龄、个数)</label><br />
                    <input id="RB_Float" type="radio" name="Field_Type" value="3" /><label for="RB_Float">浮点类型(身高、体重、长度)</label><br />
                    <input id="RB_Money" type="radio" name="Field_Type" value="8" /><label for="RB_Money">金额类型(应付、应收、单价)</label><br />
                    <input id="RB_Date" type="radio" name="Field_Type" value="6" /><label for="RB_Date">日期类型(出生日期、还款日期)</label><br />
                    <input id="RB_DateTime" type="radio" name="Field_Type" value="7" /><label for="RB_DateTime">日期时间类型(发生时间、出发时间)</label><br />
                    <input id="RB_Boolen" type="radio" name="Field_Type" value="4" /><label for="RB_Boolen">Boolen型(是否同意、是否结算)</label><br />
                    <input id="RB_SignCheck" type="radio" name="Field_Type" value="14" /><label for="RB_SignCheck">签批组件</label> - <a href="https://www.bilibili.com/video/BV1EK411T7U4" target="_blank" >视频教程</a><br />
                    <label><input id="RB_FlowBBS" type="radio" name="Field_Type" value="15" />评论(抄送意见)组件</label><br />
                </td>
            </tr>
            <tr>
                <td>英文字段<font color=gray>(必须以下划线字母开头) </font></td>
            </tr>
            <tr>
                <td>
                    <input id="TB_KeyOfEn" class="easyui-textbox" style="width: 200px" />
                </td>
            </tr>
            <tr>
                <td>
                    <input id="RB_qp" type="radio" name="RB_qpjp" checked="checked" value="ziduanquanpin" /><label for="RB_qp">字段全拼</label>
                    <input id="RB_jp" type="radio" name="RB_qpjp" value="ziduanjianpin" /><label for="RB_jp">字段简拼</label>

                    <a href="#" onclick="SelectOne();" title="从数据表里选择字段" class="easyui-linkbutton" data-options="iconCls:'icon-add',toggle:true">选择字段</a>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input id="CB_scbq" type="checkbox" checked="checked" /><label for="CB_scbq">是否根据名称生成标签</label>
                    <input id="CB_sfyczd" type="checkbox" /><label for="CB_sfyczd">是否隐藏字段</label>

                </td>
            </tr>
        </table>
    </form>
</body>
</html>
